package com.dubbo.cp.logcenter.consumer;

import org.apache.kafka.clients.consumer.ConsumerRecord;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.kafka.annotation.KafkaListener;
import org.springframework.stereotype.Component;

import com.dubbo.cp.logcenter.entity.LogEntity;
import com.dubbo.cp.logcenter.mapper.LogMapper;

@Component
public class LogConsumer {
	
	@Autowired
	private LogMapper logMapper;
	
    @KafkaListener(groupId = "logGroup",topics = "dubbo-log")
    public void logListener1(ConsumerRecord<?, ?> cr) throws Exception {

		LogEntity entity=new LogEntity();
		entity.setLogText((String)cr.value());
		logMapper.insert(entity);
    }
}
